package me.zk.practice1.hw;

import java.util.HashSet;
import java.util.Set;

/**
 * @author zhangkai
 * @date 2023/8/4 16:31
 */
public class SB08 {

    public static void helper(String[] strs) {
        Set<String> res = new HashSet<>();
        boolean[] isUsed = new boolean[strs.length];
        helper(0,strs,res,new StringBuffer(),isUsed);

        System.out.println(res);
    }

    public static void helper(int depth,String[] strs,Set<String> res,StringBuffer sb, boolean[] isUsed) {

        if (depth == strs.length) {
            res.add(sb.toString());
            return;
        }

        for (int j = 0; j < strs.length; j++) {
            if (!isUsed[j]){
                sb.append(strs[j]);
                isUsed[j]=true;
                helper(depth+1,strs,res,sb,isUsed);
                isUsed[j]=false;
            }
        }

    }

    public static void main(String[] args) {
        helper(new String[]{"a","b","c"});
    }
}
